package com.erlang.spring.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Description：jdk动态代理
 */
public class JdkProxy implements InvocationHandler {

    private Object targClass;

    private String joinPoint = "saveAccount";

    public JdkProxy(Object targClass) {
        this.targClass = targClass;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object object = null;
        if (joinPoint.equals(method.getName())){
            System.out.println("JDK增强："+method.getName());
        }
        object = method.invoke(targClass, args);
        return object;
    }
}